<?php
/**
 * article_edit.inc
 * Template: Edit an article.
 * @copyright	Copyright(c) 2002-2010 Bjorn Winberg
 * @author		Bjorn Winberg <cms@anomalye.net>
 * @license		http://www.gnu.org/licenses/gpl.html GNU General Public License version 2
 * @package		AnomalyWiki
 */
	$this->mSystem->mHtmlHeaders[] = '<link type="text/css" href="' . $this->getSkinUrl('article_edit.css') . '" rel="stylesheet" />';
?>
<h1><?php echo $this->localString('EF_TITLE');?></h1>
<?php
	echo $this->generateMenu('article', 'EDIT', 'subMenu');
?>
<div class="helpBox">
	<?php echo $this->localString('EF_HELP');?>
</div>

<div class="simpleForm">
<form action='<?php echo $this->generateUrl('article', array('a' => 'edit', 'name' => $aParams['name']));?>' method='POST' id='article_editForm'>
	<fieldset>
	<legend><?php echo $this->localString('EF_EDIT_LEGEND', array($this->getSafeStr($aParams['name'])));?></legend>
	<div class="simpleRequired">
		<label for="articleBody"><?php echo $this->localString('EF_EDIT_LABEL');?></label>
		<textarea rows='15' cols='60' name='articleBody' id='articleBody'><?php
			if($aParams['article'] !== false){
				echo $this->getSafeStr($aParams['article']['content']);
			}
		?></textarea>
	</div>
	<input type='submit' name='submit' value="<?php echo $this->localString('EF_SUBMIT');?>" />
	<input type='submit' name='preview' value="<?php echo $this->localString('EF_PREVIEW');?>" />
	</fieldset>
</form>
</div>

<?php
	if(isset($aParams['preview'])){
		echo $aParams['preview'];
		return;
	}
?>

<form class="simpleForm" id="article_newForm" action="<?php echo $this->generateUrl('article', array('a' => 'edit_form'));?>" method='POST'>
	<fieldset>
	<legend><?php echo $this->localString('EF_NEW_LEGEND');?></legend>
	<div class="simpleRequired">
		<label for="name"><?php echo $this->localString('EF_NEW_NAME');?></label>
		<input type='text' id='name' name='name' value="" maxlength="<?php echo Article::PARAM_MAX_ITEM_NAME;?>" />
	</div>
	<input type='submit' name='submit' value="<?php echo $this->localString('EF_SUBMIT_NEW');?>" />
	</fieldset>
</form>